package StudyCode.summary.textfile;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.UserPrincipal;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class SetPosixOwners {
	public static void main(String[] args) {
		Path path = Paths.get("E:/Copy/test1.txt");
		try {
			UserPrincipal group = path.getFileSystem()
					.getUserPrincipalLookupService()
					.lookupPrincipalByName("apressteam");
			Files.getFileAttributeView(path, PosixFileAttributeView.class).setOwner(group);
		} catch (IOException e) {
			System.err.println(e);
		}

	}
}
